//
// Created by chizuru on 2025/9/2.
//

#pragma once
#include "ICommand.h"
#include "CameraDevice.h"

// RegisterWriteCommand: ops one register, can optionally record previous value (for undo)
class RegisterWriteCommand : public camera_link_bobcat::ICommand {
public:
    RegisterWriteCommand(CameraDevice& comm, uint16_t addr, uint32_t value, RetryPolicy rp, bool captureOriginal=false);
    bool execute() override ;

    // undo will attempt to restore original value if captured
    bool undo() override ;

    uint16_t addr() const ;
    uint32_t value() const ;

private:
    CameraDevice& comm;
    uint16_t _addr;
    uint32_t _value;
    RetryPolicy rp;
    bool captureOriginal;
    uint32_t originalValue{0};
    bool haveOriginal{false};
    bool done{false};
};

